package cn.bytecollege.admin.dao;

import cn.bytecollege.common.dao.BaseDao;
import cn.bytecollege.common.entity.Merchant;
import cn.bytecollege.common.entity.Orders;
import com.mysql.cj.x.protobuf.MysqlxCrud;

import java.util.List;

public class OrdersDao extends BaseDao <MysqlxCrud.Order,Integer> {
    /**查询订单信息
     *
     * @param pageIndex
     * @param pageSize
     * @return
     */
    public List<Orders> findOrdersByPage(int pageIndex, int pageSize){
        String sql = "SELECT ORDERS_ID,USER_ID,CREATE_TIME,ADDRESS_ID,PRODUCT_SUM_PRICES,PAYMENT_STATE,ORDER_NUMBER "
                +"FROM ORDERS LIMIT ?,?";
        int index = (pageIndex-1)*pageSize;
        return helper.executeQuery(sql,Orders.class,index,pageSize);
    }

    /**
     * 查询总订单数
     * @return
     */
    public int count(){
        String sql = "SELECT COUNT(*) FROM ORDERS";
        return helper.executeScale(sql);
    }

}
